//
//  SetTableView.m
//  yunqiphone
//
//  Created by Maple on 13-7-12.
//  Copyright (c) 2013年 ci123.com. All rights reserved.
//

#import "SetTableView.h"

@implementation SetTableView

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    if (self) {
        self.delegate = self;
        self.dataSource = self;
    }
    return self;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identify = @"SetCell";
    UITableViewCell *cell = [self dequeueReusableCellWithIdentifier:identify];
    if(cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify];
        
        UIView *back = [[UIView alloc] initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, 47)];
        back.backgroundColor = [UIColor whiteColor];
        cell.backgroundView = back;
        CALayer *borderBottom = [CALayer layer];
        borderBottom.backgroundColor = DefaultBorderColor.CGColor;
        borderBottom.frame = CGRectMake(0, back.height - .5f, back.width, .5f);
        [back.layer addSublayer:borderBottom];
        
        if (indexPath.section == 0 && indexPath.row == 0) {
            CALayer *borderTop = [CALayer layer];
            borderTop.backgroundColor = RGBCOLOR(227, 227, 229).CGColor;
            borderTop.frame = CGRectMake(0, 0, back.width, .5f);
            [back.layer addSublayer:borderTop];
        }

    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor = RGBCOLOR(61, 61, 61);
    cell.textLabel.font = [UIFont systemFontOfSize:17];
    cell.textLabel.highlightedTextColor = cell.textLabel.textColor;

    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
    cell.detailTextLabel.textColor = RGBCOLOR(141, 141, 141);
    cell.detailTextLabel.font = [UIFont systemFontOfSize:17];
    cell.detailTextLabel.highlightedTextColor = cell.detailTextLabel.textColor;
    }
    if(![_noAccess containsObject:[NSString stringWithFormat:@"%ld", (long)indexPath.row]]) {
        UIImageView *access= [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 14, 14)];
        access.image = [UIImage imageNamed:@"set_right_open"];
        cell.accessoryView = access;
    }else{
        cell.accessoryView = nil;
        UIView *view = [[UIView alloc] init];
        cell.selectedBackgroundView = view;
    }

    cell.textLabel.text = _data[indexPath.row];
    cell.detailTextLabel.text= _detailData[indexPath.row];

    return cell;
}

 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 return [_data count];
 }
 
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
 return 47;
 }

@end
